
struct Mipmap{ ///Yes yes, it isnt a mipmap

int drawx, drawy;

sf::Image Map;

SSystem *System;

int width, height;

Mipmap(SSystem *pSystem, int pwidth, int pheight){
    load(pSystem, pwidth, pheight);
}

void load(SSystem *pSystem, int pwidth, int pheight){

    System=pSystem;
    width=pwidth;
    height=pheight;

   // Map=SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0, 0, 0, 0);
   Map.Create(width, height);
    //if(Map==NULL){
    //    exit(123);
    //}



}
void clear(){

//SDL_FreeSurface(Map);

//Map=SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0, 0, 0, 0);
//SDL_FillRect(Map, NULL, 0x00ff00ff);

Map.Create(width, height);
}

void process(int x, int y){


    for(int i=0; i<System->number; i++){


        //int distance=(((abs(System->PlanetManagements[i].fromsun)/200)/1000/2)); ///This is all wrong
        //if(abs(System->PlanetManagements[i].fromsun)>System->PlanetManagements[i].fromsun){
        //distance=100-distance;
        //}
        //else{

        //}

        PlanetHandler *P=&System->PlanetManagements[i];

        //int magnitude = sqrt(pow(P->x, 2) + pow(P->y, 2));


        double px, py;

        //x=((P->x/magnitude)*100) +100;
        //y=((P->y/magnitude)*100) +100;

        /*double a;
        a=abs(P->x);
        a=a/200.0;
        a=a/1000;
        a=a/2.0;
        a=a;

        if(P->x<0){

            a=100-a;
        }
        else{
            a=a+100;

        }

        px=a;

        a=abs(P->y);
        a=a/200.0;
        a=a/1000;
        a=a/2.0;
        a=a;

        if(P->y<0){

            a=100-a;
        }
        else{
            a=a+100;

        }

        py=a;*/


        Sint64 b;
        long double a;
        b=P->x;
        a=(long double)b/(Uint64)MAX_SOLAR;


        a=(a*(width))/2.0;

        px=a+height/2;


        b=P->y;
        a=(long double)b/(Uint64)MAX_SOLAR;
        a=(a*(height))/2.0;

        py=a+height/2;
        //std::cout << "\na\n" << py;



        //b=P->y;
        //py=100;

        //printf("X:%i\n", px);
        //std::cout << P->x << "x" << std::endl;

         //printf("Distance:%i\n", System->PlanetManagements[i].fromsun/200.0/1000.0/2.0);
         //printf("Distance:%i\n", distance);
        sf::Color C=sf::Color(254, 254, 254);
        Set_pixel(&Map, px, py, C);

    }

    Set_pixel(&Map, ((x/200)/1000)/2 + 100, (y/200/1000/2) + 100, sf::Color(255, 0, 0));

    //SDL_Delay(2000);
}

Mipmap(){}


};
